/* ptsdd.t   BOM STRUCTURE SUBSTITUTE PUR PCT DELETE TRIGGER                 */

	TRIGGER PROCEDURE FOR DELETE OF fpx_mstr.

    {mfdeclre.i }
    define new shared work-table wf_old_fpx_mstr like fpx_mstr.

	HK:
	do:
        if can-find(first dt_mstr where dt_table = "fpx_mstr" and dt_type = "SYNC") then
            run CreateSyncFlag(input "DEL", input recid(fpx_mstr), input "fpx_mstr").

        if not can-find ( first dt_mstr where dt_table = "fpx_mstr" and dt_type = "DEL" ) then leave HK.
        
        if not can-find ( first wf_old_fpx_mstr ) then do:
            create wf_old_fpx_mstr.
            if recid(wf_old_fpx_mstr)= -1 then .
        end.
        
        buffer-copy fpx_mstr to wf_old_fpx_mstr no-error.

        for first dt_mstr no-lock where dt_table = "fpx_mstr" and dt_type = "DEL" :
        
    	    run CreateDthist(input dt_table, input dt_field, input dt_type, input "", input "", 
                    input recid(fpx_mstr), input string(fpx_mstr.fpx_start), input fpx_mstr.fpx_site, input fpx_mstr.fpx_part, input fpx_mstr.fpx_cust,
        	    input "", input "", input "", input "") .
			
        end.
   end.

{hkdttrans.i}
